home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $VER: DBatchFTP.thor 1.0 (07.08.97)
- **
- ** ############################ DBatchFTP.thor ############################
- ** ######################## by David Stroud (Newt) ########################
- ** ############################# Version 1.00 #############################
- **
- ** The basis for this script came from CalcDL.thor by Eirik Nicolai Synnes,
- ** to whom I must extend my thanks in making the task somewhat easier!
- **
- ** I also made use of AutoReply.br for the event creation. Thanks to Neil
- ** Bothwick for that script :)
- **
- ** This is my first ARexx script ever, so if I've done anything wrong or
- ** silly, please excuse me. Any suggestions/comments are gratefully
- ** received. Email me at:
- **
- ** DaveStroud@nebula.demon.co.uk
- **
- ** ...or make your feelings known on the Thor Mailing list so everyone
- ** can have a laugh at my ARexx scripting technique :)
- */
-
- /**************************************************************************
- ** Please change the following variables to suit your configuration... **
- **************************************************************************/
-
- /* aminet_server: No trailing colon! *************************************/
- /* aminet_basedir: Please include leading and trailing slashes. **********/
- /* demon_bftp: Address for batch FTP requests to be sent. ****************/
- /* email_conf: The name of your main Email conference on your system *****/
-
- aminet_server = "ftp.uk.aminet.org"
- aminet_basedir = "/pub/aminet/"
- demon_bftp = "ftp@demon.net"
- email_conf_name = "Email"
-
- /* ########################################################################
- ** ############### DO NOT EDIT ANYTHING BELOW THIS LINE! ##################
- ** ########################################################################
- */
-
- options results
-
- /* Find Thor and BBSREAD ARexx ports' */
- p=address()||' '||show('P',,)
- if pos(' THOR.',p)>0 then thorport=word(substr(p,pos(' THOR.',p)),1)
- else do
- say 'No THOR port found!'
- exit(0)
- end
- if ~show('p', 'BBSREAD') then do
- address command
- "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
- "WaitForPort BBSREAD"
- end
-
- address(thorport)
- 'CURRENTSYSTEM STEM 'curbbs
- if rc > 1 then do
- 'REQUESTNOTIFY "CURRENTSYSTEM: 'THOR.LASTERROR'" "Ok"'
- exit(0)
- end
-
- address(bbsread)
- 'GETBBSDATA BBSNAME "'curbbs.BBSNAME'" STEM 'bbsdata
- if rc ~= 0 then do
- address(thorport)
- 'REQUESTNOTIFY "GETBBSDATA: 'BBSREAD.LASTERROR'" "Ok"'
- exit(0)
- end
-
- /* Temporary counter and file-opened indicator*/
- tcount = 0
- tfile = 0
-
- /* If there's any events */
- if bbsdata.NUMEVENT > 0 then do eventnum = bbsdata.FIRSTEVENT to bbsdata.LASTEVENT
-
- /* examine an event's data */
- address(bbsread)
- 'READBREVENT BBSNAME "'curbbs.BBSNAME'" EVENTNR 'eventnum' TAGSSTEM ETAG DATASTEM' EDATA
-
- /* if not successful, exit showing error */
- if rc ~= 0 then do
- address(thorport)
- 'REQUESTNOTIFY "READBREVENT: 'BBSREAD.LASTERROR'" "Ok"'
- exit(0)
- end
-
- /* Debugging bit (pretend you didn't notice ;)
- ** say 'Event Num :' eventnum
- ** say ' Event flags:' c2x(EDATA.FLAGS)
- ** say ' Event type :' EDATA.EVENTTYPE
- */
-
- /* otherwise, do this... */
- /* if the event is a download */
- if EDATA.EVENTTYPE = 4 then do
-
- /* Another debug bit
- ** say eventnum bittst(EDATA.FLAGS, 0) bittst(EDATA.FLAGS, 1) bittst(EDATA.FLAGS, 2) bittst(EDATA.FLAGS, 3) bittst(EDATA.FLAGS, 4) bittst(EDATA.FLAGS, 5) bittst(EDATA.FLAGS, 6)
- */
- /* say c2x(EDATA.FLAGS) */
- if ~bittst(edata.FLAGS, 0) & bittst(edata.FLAGS, 5) then do
-
- if ~(ETAG.DIRECTORY = 'ETAG.DIRECTORY') then do
-
- if tfile=0 then do
- /* Create message file for reply */
- address(bbsread)
- UNIQUEMSGFILE bbsname '"'curbbs.BBSNAME'"' stem MsgFile
- if ~open(out,MsgFile.NAME,'w') then do
- address(thorport)
- 'REQUESTNOTIFY "Could not open file for data!\n\nI know, this shouldn`t happen." "Erk!"'
- exit(0)
- end
- tfile=1
- end
- /* write the event to the datafile in the batchftp format */
- call writeln(out,''aminet_server':'aminet_basedir''ETAG.DIRECTORY'/'ETAG.FILENAME'')
- tcount=tcount+1
- end
- end
- end
- end
-
- /* Close file */
- call close(out)
-
- EventData.TOADDR = demon_bftp
- EventData.SUBJECT = 'Batch-FTP request'
- EventData.CONFERENCE = email_conf_name
- EventData.MSGFILE = MsgFile.FILEPART
- EventData.TONAME = 'Demon Batch-FTP'
-
- if tfile=1 then do
- WRITEBREVENT bbsname '"'curbbs.BBSNAME'"' event 0 stem EventData
- if RC > 0 then do
- address(thorport)
- 'REQUESTNOTIFY "Houston, we have a problem:\n\nWRITEBREVENT returned: 'RC'" "Poohsticks."'
- exit(0)
- end
- end
-
- if tcount=0 then do
- address(thorport)
- 'REQUESTNOTIFY "No frozen download events were\n picked up by DBatchFTP.thor!" "Hmmm, okay."'
- exit(0)
- end
-
- address(thorport)
- 'REQUESTNOTIFY " DBatchFTP.thor has finished! \n\nA total of 'tcount' download event(s) were transmogrified." "Smokin!"'
-
- exit(0)
-
-